import Drawable from "../Domain/Drawable";
import DrawableParser from "../Domain/DrawableParser";
import DrawableContainer from "./DrawableContainer";
import LineContainer from "./LineContainer";

const {ccclass, property} = cc._decorator;

@ccclass
export default class DashBoard extends cc.Component {

    private drawable: Drawable = null
    @property(DrawableContainer)
    private drawableContainer: DrawableContainer = null


    @property(LineContainer)
    private lineContainer: LineContainer = null

    public async setDrawable(id: string) {
        this.drawable = await DrawableParser.get(id)
        console.log("加载资源内容:", this.drawable)
        this.drawableContainer.init(this.drawable)
        this.lineContainer.init(this.drawable)
    }

    start() {
        this.node.on(cc.Node.EventType.TOUCH_START, function () {
            this.lineContainer.startDraw()
        }.bind(this))

        this.node.on(cc.Node.EventType.TOUCH_END, function () {
            this.lineContainer.endDraw()
        }.bind(this))
    }

}
